package com.zbkj.crmeb.enums.plat;

import org.apache.commons.lang3.StringUtils;

import java.util.*;

public enum PlatPushStatusEnums {
    BY_UP("BY_UP","已推送别样"),
    BY_DOWN("BY_DOWN","别样已下架"),
    DW_UP("DW_UP","已推送得物"),
    DW_DOWN("DW_DOWN","得物已下架"),
    DY_UP("DY_UP","已推送抖音"),
    DY_DOWN("DY_DOWN","抖音已下架"),
    PUSH_WAIT("PUSH_WAIT","待推送"),
    PUSH_TASK("PUSH_TASK","推送中"),
    PUSH_FAIL("PUSH_FAIL","推送失败"),
    OTHER("OTHER","")
    ;
    private String code;
    private String desc;

    PlatPushStatusEnums(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(String code){
        if (StringUtils.isBlank(code)){
            return PUSH_WAIT.getDesc();
        }
        for (PlatPushStatusEnums value : PlatPushStatusEnums.values()) {
            if (Objects.equals(value.getCode(),code)){
                return value.getDesc();
            }
        }
        return PUSH_WAIT.getDesc();
    }

    public static List<Map<String, String>> listEnum() {
        List<Map<String, String>> list = new ArrayList<>();
        for (PlatPushStatusEnums value : PlatPushStatusEnums.values()) {
            Map<String, String> map = new HashMap<>();
            map.put("key", value.getDesc());
            map.put("value", value.getCode());
            list.add(map);
        }
        return list;
    }
}
